<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
	<%@ include file="/common/include.jsp" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String bloguserid = request.getParameter("bloguserid");
	String blogusername = request.getParameter("blogusername");
	
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title></title>
		<meta http-equiv="content-Type" content="text/html; charset=utf-8" />
		<meta name="robots" content="all" />
		<meta name="MSSmartTagsPreventParsing" content="true" />
		<meta http-equiv="imagetoolbar" content="false" />
		   <script type="text/javascript" src="<%=path %>/script/jquery.js"></script>
   <script type="text/javascript" src="<%=path %>/script/jLook/jLook-latest.js"></script>

	</head>

	<body>
	<p style="display: none">Hello</p> 
<input type="hidden" value="<%=bloguserid %>" name="bloguserid" id="bloguserid">
<input type="hidden" name="blogusername" id="blogusername" value="<%=blogusername %>">
			<div id="DialogContent"
				style="padding: 10px 0pt 0pt 25px; text-align: left;color:red;" >
				给<%=blogusername %>留句话吧！
				<br>
				<textarea id="content" name="content" rows="5" cols="32"></textarea>
				<br>
				<br>
				请输入验证码:
				<br>
				<input size="4" maxlength="4" id="validateCode"
					style="font-size: 20px;" type="text" name="validateCode">
				&nbsp;&nbsp;
			<img  id ='imgId' src="servlet/createimage" onclick="this.src+='?'+Math.floor(Math.random()*10);" alt="点击刷新" />点图
			<a href ="javascript:refrash()">刷新</a>
			</div>
			<br><br>
			<div id="DialogButtons">
				<button id="FriendDel"
					onclick="saveGoodFriend();">
					加为好友
				</button>
				&nbsp;&nbsp;&nbsp;&nbsp;
				<button id="AddFriendCancle" onclick="reset();">
					取消
				</button>
			</div>
		 
	</body>
	<script type="text/javascript">
	function saveGoodFriend(){
			var bloguserid =$('#bloguserid').val();
			var blogusername =$('#blogusername').val();
			var content =$('#content').val();
			var validateCode =$('#validateCode').val();
			if(validateCode==""||validateCode==null ) 
			{
			alert("请填写验证码!")
			$("#validateCode").focus();
			  return;
			} 
		var sendData="bloguserid="+bloguserid+"&blogusername="+encodeURIComponent(blogusername)+"&content="+encodeURIComponent(content)
		+"&validateCode="+validateCode;
	
		$.ajax({ 
			url: "<%=request.getContextPath()%>/saveGoodFriend.do" ,
			type:'post', //数据发送方式 
			dataType:'action', //接受数据格式 
			data: sendData , 
			success:function(data){ 
                  if(data=="0"){ 
					alert("您输入的密码有误，请重新输入!");
                  }else if(data=="1"){
                     alert("加为好友!等待好友审核!");
                     window.location.reload();
                  }
                }
			
			,
           error:function(data){
             alert("保存出错,请重新尝试！");
           }
		}); 
	}
	
	function reset(){
		document.getElementById("content").value="";
		document.getElementById("validateCode").value="";
	}
	</script>
</html>
